﻿using Rhino;
using Rhino.UI;

namespace AiMoRhino.Preview
{
    class MouseClick : MouseCallback
    {
        readonly Previewer owner;
        public MouseClick(Previewer owner)
        {
            this.owner = owner;
        }
        bool _mouseDown = false;
        protected override void OnEndMouseUp(MouseCallbackEventArgs e)
        {
            if (_mouseDown && owner.PreviewRec.Contains(e.ViewportPoint))
            {
                _mouseDown = false;
                owner.ClosePreview();
            }
        }
        protected override void OnMouseDown(MouseCallbackEventArgs e)
        {
            if ((!owner.IsEmpty) && owner.PreviewRec.Contains(e.ViewportPoint))
            {
                e.Cancel = true;
                _mouseDown = true;
                RhinoDoc.ActiveDoc.Views.Redraw();
            }
        }
    }
}
